﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Workflow.Application.DTOs.Input;
using Microsoft.Extensions.Logging;
using Workflow.Application.DTOs.Output;
using Workflow.Application.ErrorCode;
using Workflow.Application.IService;

namespace Workflow.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class GroupController : ControllerBase
    {
        private readonly ILogger<GroupController> logger;
        private readonly IGroupService groupService;

        public GroupController(IGroupService groupService, ILogger<GroupController> logger)
        {
            this.groupService = groupService;
            this.logger = logger;
        }
        

        /// <summary>
        /// 获取流程模板分组列表
        /// </summary>
        /// <returns>流程模板分组列表</returns>
        [HttpPost]
        public async Task<ApiResult<List<WorkflowGroupDto>>> GetGroups()
        {
            return await groupService.GetGroupsAsync();
        }


        /// <summary>
        /// 添加流程模板分组
        /// </summary>
        /// <param name="input">分组信息</param>
        /// <returns>添加结果</returns>
        [HttpPost]
        public async Task<ApiResult<long>> AddGroup(AddGroupInput input)
        {
            return await groupService.AddGroupAsync(input);
        }
    }
}
